import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';

import 'routes.dart';

void main() {
  ///初始化并配置路由
  Routes.configureRoutes(Router());
  runApp(MaterialApp(onGenerateRoute: Routes.router.generator));
}

const titles = ['材料动效', '2', '3'];
List<VoidCallback> toDoList = List();

class PageRoot extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('flutter animation'),
      ),
      body: ListView.separated(
        separatorBuilder: (context, index) => Divider(
          color: Colors.amberAccent,
        ),
        itemBuilder: (context, index) => GestureDetector(
          onTap: () {
            if (index == 0) {
              String route = '${Routes.material}';
              Routes.router.navigateTo(context, route,
                  replace: false, transition: TransitionType.fadeIn);
            } else if (index == 1) {
              String route = '${Routes.hero}';
              Routes.router.navigateTo(context, route,
                  replace: false, transition: TransitionType.fadeIn);
            }
          },
          child: Card(
              elevation: 0,
              color: Colors.transparent,
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(
                  titles[index],
                  style: TextStyle(fontSize: 16),
                ),
              )),
        ),
        itemCount: titles.length,
      ),
    );
  }
}
